<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Model;

class Linkslistshtmls extends Model
{
    protected $table = 'links_lists_htmls';
    protected $primaryKey = 'id';

    public static function checkLinksListsHtmlsExist($links_id,$status)
    {
        return self::select("id")->where("links_id",$links_id)->where("status",$status)->first();
    }

    public static function getLinksListsHtml($links_id,$status)
    {
        return self::select("html","script")->where("links_id",$links_id)->where("status",$status)->first();
    }

    public static function getLinksListsHtmls($links_id)
    {
        return self::where("links_id",$links_id)->orderBy("id","DESC")->first();
    }

    public static function linksListHtml($links_id)
    {
        return self::where("links_id",$links_id)->orderBy("id","DESC")->first();
    }

    public static function createLinkListHtml($links_id,$title,$html)
    {
        return self::insert(["links_id"=>$links_id,"title"=>$title,"html"=>$html,"created_at"=>time()]);
    }

    public static function updateLinksListsHtmls($links_id,$html,$status)
    {
        return self::where("links_id",$links_id)->where("status",$status)->update(["html"=>$html]);
    }

    public static function createLinksListsHtmls($links_id,$html,$status)
    {
        return self::insert(["links_id"=>$links_id,"html"=>$html,"status"=>$status,"created_at"=>time()]);
    }

    public static function updateLinkListHtml($links_id,$title,$html,$redirect_type,$copyright)
    {
        return self::where("links_id",$links_id)->update(["title"=>$title,"html"=>$html,"redirect_type"=>$redirect_type,"copyright"=>$copyright]);
    }
}
